--! qt:dataset:src
-- SORT_QUERY_RESULTS

set hive.order.columnalignment=false;

CREATE TABLE DEST2_n31_2(key INT, val1 STRING, val2 STRING) STORED AS TEXTFILE;

EXPLAIN
FROM SRC
INSERT OVERWRITE TABLE DEST2_n31_2 SELECT SRC.key, SRC.value, COUNT(DISTINCT SUBSTR(SRC.value,5)) GROUP BY SRC.key, SRC.value;

FROM SRC
INSERT OVERWRITE TABLE DEST2_n31_2 SELECT SRC.key, SRC.value, COUNT(DISTINCT SUBSTR(SRC.value,5)) GROUP BY SRC.key, SRC.value;

SELECT DEST2_n31_2.* FROM DEST2_n31_2;

DROP TABLE DEST2_n31_2;
